package net.lijingye.education.entity;

import org.springframework.core.annotation.Order;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * Created by LijingYe on 2016/4/4.
 */
@Entity
@Table(name = "class")
public class Lesson implements Serializable {
    @Id
    @Column(name = "classId")
    private String id;

    @Column(name = "classStatus")
    private int status;

    @OneToOne
    @JoinColumn(name = "courseId")
    private Course course;

    @OneToOne
    @JoinColumn(name = "userId")
    private User user;

    @OneToOne
    @JoinColumn(name = "termId")
    private Term term;

    @OneToMany
    @JoinColumn(name = "classId")
    @OrderBy("time desc")
    private List<PPT> pptList;

    @OneToMany
    @JoinColumn(name = "classId")
    @OrderBy("time desc")
    private List<Assignment> assignmentList;

    @OneToMany
    @JoinColumn(name = "classId")
    @OrderBy("time desc")
    private List<Source> sourceList;

    @OneToMany
    @JoinColumn(name = "classId")
    @OrderBy("time desc")
    private List<Topic> topicList;

    @ManyToMany
    @JoinTable(name = "student_class", joinColumns = {@JoinColumn(name = "classId")}, inverseJoinColumns = {@JoinColumn(name = "userId")})
    private List<User> studentList;

    public Lesson() {
    }

    public Lesson(String id, int status, Course course, User user, Term term, List<PPT> pptList, List<Source> sourceList, List<Topic> topicList, List<User> studentList) {
        this.id = id;
        this.status = status;
        this.course = course;
        this.user = user;
        this.term = term;
        this.pptList = pptList;
        this.sourceList = sourceList;
        this.topicList = topicList;
        this.studentList = studentList;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Term getTerm() {
        return term;
    }

    public void setTerm(Term term) {
        this.term = term;
    }

    public List<PPT> getPPTList() {
        return pptList;
    }

    public void setPPTList(List<PPT> pptList) {
        this.pptList = pptList;
    }

    public List<Source> getSourceList() {
        return sourceList;
    }

    public void setSourceList(List<Source> sourceList) {
        this.sourceList = sourceList;
    }

    public List<PPT> getPptList() {
        return pptList;
    }

    public void setPptList(List<PPT> pptList) {
        this.pptList = pptList;
    }

    public List<Topic> getTopicList() {
        return topicList;
    }

    public void setTopicList(List<Topic> topicList) {
        this.topicList = topicList;
    }

    public List<User> getStudentList() {
        return studentList;
    }

    public void setStudentList(List<User> studentList) {
        this.studentList = studentList;
    }

    public List<Assignment> getAssignmentList() {
        return assignmentList;
    }

    public void setAssignmentList(List<Assignment> assignmentList) {
        this.assignmentList = assignmentList;
    }
}
